// 引入baseUrl 来自config.js文件
import {baseUrl} from './config.js';


// 登录接口
export function _login(phone,password){
	return uni.request({
		url:`{baseUrl}/login/cellphone`,
		method:'POST',
		params:{
			phone:phone,
			password:password
		}
	})
}

// 获取banner图

export function banner(bannerId){
	return uni.request({
		url:`${baseUrl}/banner?type= +2+ `  ,
		method:'GET'
	})
}

// 获取banner图

// 获取推荐歌单
export function personalized(limiId){
	return uni.request({
		url:`${baseUrl}/personalized?limit= +10+ `  ,
		method:'GET'
	})
}


// 获取排行榜数据
export function toplist(){
		var listIds = ['19723756' , '3779629' , '2884035' , '3778678',];
		return new Promise(function (reslove,reject) {
		uni.request({
			url:`${baseUrl}/toplist/detail`,
			method:'GET',
			// 成功的结果
			success:res =>{
				// console.log(res)
				let result =res.data.list;
				result.length = 4;
				for(var i=0;i<listIds.length;i++){
					result[i].listId = listIds[i]; 
				}
				reslove(result);
			}
		})
	}) 
}

// 获取所有排行榜数据
export function songtoplists(){
	return new Promise(function(reslove,reject){
		uni.request({
			url:`${baseUrl}/toplist`,
			method:'GET',
			success: res => {
				let result = res.data.list;
				reslove(result);
			}
		})
	})
	
}




// 获取列表接口进行渲染页面
export function list(listId){
return uni.request({
		// url:`${baseUrl}/top/list?id=${listId}`,
		url:`${baseUrl}/playlist/detail?id=${listId}`,
		method:'GET'
	});
}



// 获取歌曲详细信息
export function songDetail(songId){
return uni.request({
		url:`${baseUrl}/song/detail?ids=${songId}`,
		method:'GET'
	});
}

// 获取相似音乐
export function songSimi(songId){
return uni.request({
		url:`${baseUrl}/simi/song?id=${songId}`,
		method:'GET'
	});
}



//获取歌曲评论信息 
export function songComment(songId){
return uni.request({
		url:`${baseUrl}/comment/music?id=${songId}`,
		method:'GET'
	});
}


// 获取歌词信息接口
export function songlyric(songId){
return uni.request({
		url:`${baseUrl}/lyric?id=${songId}`,
		method:'GET'
	});
}

// 获取歌曲信息
// export function songUrl(songId){
// return uni.request({
// 		url:`${baseUrl}/song/url?id=${songId}`,
// 		method:'GET'
// 	});
	
// }

// 获取音频地址
export function songUrl(songId){
	return uni.request({
		url : `${baseUrl}/song/url?id=${songId}`,
		method : 'GET'
	})
}

// 获取搜索接口
export function searchHot(){
	return uni.request({
		url : `${baseUrl}/search/hot/detail`,
		method : 'GET'
	})
}

// 查询提示歌曲信息
export function searchWord(Word){
	return uni.request({
		url : `${baseUrl}/search?keywords=${Word}`,
		method : 'GET'
	})
}

//搜索
export function searchSuggest(Word){
	return uni.request({
		url : `${baseUrl}/search/suggest?keywords= ${Word}&type=mobile`,
		method : 'GET'
	})
}

// 相关歌单 推荐 /personalized
export function songsquare(limiId){
	return uni.request({
		url:`${baseUrl}/personalized?limit= +9+ `  ,
		method:'GET'
	})
}

// 获取热门话题
export function topic(){
	return uni.request({
		url:`${baseUrl}/hot/topic`,
		method:'GET'
	})
}